<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  String xm = this.getServletContext().getInitParameter("path");
	String path1 = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+xm;
%>   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改接待信息</title>
<link href="<%=path1%>/css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path1%>/scripts/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/jquery-1.7.2.min.js"></script>
<!--[if IE 6]>
<script type="text/javascript" src="js/ie6png.js" ></script>
<script type="text/javascript">
DD_belatedPNG.fix('div,ul,li,a,p,img,body,dl,dt,dd');</script>
<![endif]-->
<script type="text/javascript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
<script type="text/javascript">
var select1Search=''; 
$(document).ready(function(){

	var id;
    var str=window.location.href; //得到地址
    //alert("str"+str);
    var es=/id=/; 
    es.exec(str); //得到地址后面变量名称
    //alert("es--"+es.exec(str));
    var right=RegExp.rightContext;//得到地址后面变量名称的值
    alert("right"+right);

    id=right;//将结果赋值给id
    if(id!="" )
	  {
	     select1Search ="and reception_record_id='"+id+"'";
	     select1();
	  }  

});
</script>
<script type="text/javascript">
//修改
function ajaxUpdate(){
	//alert("reception_mode"+$("input[name='reception_mode']:checked").val());
	//alert("reception_content"+$("#reception_content").val());
	//alert("user_name"+$("#user_name").val());
	//alert("number"+$("#number").val());
	//alert("user_id"+$("#user_id").val());
	//alert("clientId"+$("#clientId").val());
	var receive={
	    reception_record_id:$("#sid").val(),
		reception_mode:$("input[name='reception_mode']:checked").val(),
		reception_content:$("#reception_content").val(),
		customer_id:$("#customer_id").val(),
		customer_name:$("#customer_name").val(),
		user_name:$("#user_name").val(),
		user_id:$("#user_id").val(),
		reception_time:$("#reception_time").val(),
		number:$("#number").val()
	};
	
	//alert("receive："+receive);
    $.ajax({ 	
    data: receive,
    type:"Post",  
    dataType: 'json',  
    url:"./Reception_Record/updateReception_Record.do", 
    error:function(data){  
         alert("出错了！！");  
    },  
    success:function(data){
    	alert('接待记录修改成功！');
    	//alert(data);
    	window.location.href = 'listReception_Record.jsp'; 
     }  
     });  
 } 
// 重置
function ajaxReset(){

	$("input:radio[name='reception_mode']").eq(0).attr("checked",true);
	$("#number").val("");
	$("#user_name").val("");
	$("#reception_content").val("");
	
}
</script>
<script type="text/javascript">
   function checkreception_content(){
	  var reception_content= $("#reception_content").val();
	  if(reception_content==""){
		 alert("接待内容不能为空！"); 
		 $("#reception_content").focus();
		 return false;
	  }
	  return true;
   }
</script>
<script type="text/javascript">
function select(){
var SearchSql;
var number= $("#number").val();
//alert(number);
if(number!=""){
	SearchSql=" and u.number='"+number+"'";
}
	
	//alert("123");
	//alert("ceach:"+SearchSql);
$.ajax({
	url:"/wangda/user/selectAll.do",
    datatype:'json', 
    data:{'page':1,'rows':1,'SearchSql':SearchSql}, // 发送数据   
    error:function(data){  
        alert("出错了！！");  
   },  
   success:function(data){
   	//alert('业务员信息查询成功！');
   	//window.location.href = 'listclient.jsp'; 
   	//alert(data);
   	//console.log("---------"+data);
   	var len=data.rows.length;
   	alert("namber:"+data.rows.length);
   	if(len>0){
   		//alert( data.rows[0].id);
       	//alert( data.rows[0].user_name);
       	$("#user_id").val(data.rows[0].id),
       	$("#user_name").val(data.rows[0].user_name)
   	}else{
   		alert("这个业务员不存在！！！");
   		$("#number").val("");
   		$("#user_name").val("");
   		$("#number").focus();
   	}
   	
   }

    });
}

function select1(){
	//alert("123");
	//alert("ceach:"+Search);
	$.ajax({
    	url:"./Reception_Record/selectBySql.do",
        datatype:'json', 
        type:"Post", 
        data:{'page':1,'rows':1,'searchSql':select1Search}, // 发送数据   
        error:function(data){ 
        	alert(select1Search)
            alert("出错了！！");  
       },  
       success:function(data){ 
       	//alert('查询成功！');
       	//window.location.href = 'listclient.jsp'; 
       	//alert(data);
       	//console.log("---------"+data);
       //	alert("namber:"+data.rows.length);
       	//alert( data.rows[0].id);
       	//alert( data.rows[0].customer_name);
       	$("#sid").val(data.rows[0].reception_record_id); 
       	if(data.rows[0].reception_mode=='来电'){
       		$("input:radio[name='reception_mode']").eq(0).attr("checked",true);
		}else{
			$("input:radio[name='reception_mode']").eq(1).attr("checked",true);
		}	
       	$("#reception_content").val(data.rows[0].reception_content);
       	console.log(data.rows[0].user_id);
       	document.getElementById("user_id").value = data.rows[0].user_id;
      // 	$("#user_id").val(data.rows[0].user_id);
    	//$("#clientId").val(data.rows[0].clientId);
    	$("#customer_name").val(data.rows[0].customer_name);
    	$("#customer_id").val(data.rows[0].customer_id);
    	
    	$("#reception_time").val(data.rows[0].reception_time);
    	$("#number").val(data.rows[0].number); 
    	$("#user_name").val(data.rows[0].user_name);
       }
 
        });
}
</script>
</head>
<body>
<div class="yboxwidth boxcenter">
  <div class="ybox09">
  <input type="hidden" id="sid"/>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
       <td style="padding-left: 20px"><table border="0" cellspacing="0" cellpadding="0">
          <tr valign="top" >
            <td class="ybox11td5" ></td>
            <td class="ybox11td6" >填写接待客户信息</td>
            <td class="ybox11td7"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td4"></td>    
          </tr>
        </table></td>
        </tr>
    </table>
  </div>
  <div class="ybox02">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="margb4">
      <tr>
        <td class="ybox03td1"></td>
        <td class="ybox03td2"></td>
        <td class="ybox03td3"></td>
      </tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5"><div class="ybox05 margb8">
            <dl>
              <dt><strong>接待基本信息</strong> </dt>
            </dl>
           
          </div>
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox04table">
            <tr>
              <td width="15%" class="ybox04tdl"><span class="red">*</span>接待方式</td>
              <td width="18%" class="ybox04tdr">
                  <input type="radio" name="reception_mode" value="来电" checked="checked"/>来电 &nbsp;&nbsp;&nbsp;
                  <input type="radio" name="reception_mode" value="来访"/>来访
              </td>
             <td width="15%" class="ybox04tdl">客户姓名</td>
              <td width="18%" class="ybox04tdr">
                  <input id="customer_name" name="customer_name"type="text"  class="black12" style="width:90%;" disabled="disabled" />
              </td>
              <td width="33%" class="ybox04tdl" colspan="2"></td>
            </tr>
          </table></td>
        <td class="ybox03td6"></td>
      </tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5">
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox04table">
             
            <tr>
              <td width="15%" class="ybox04tdl">业务员编号</td>
              <td width="18%" class="ybox04tdr">
              <input name="number" type="text"  class="user_id" id="user_id" style="width:85%;" />
              <img src="images/select.gif"  style="cursor: pointer;" onclick="select()" />
               </td>
              <td width="15%" class="ybox04tdl"> 业务员姓名</td>
              <td width="18%" class="ybox04tdr"><input name="user_name" type="text"  class="black12" id="user_name" style="width:90%;"  /></td>
            <td width="33%" colspan="2" class="ybox04tdl"></td>  
              </tr>
              <tr>
                  <td width="15%" class="ybox04tdl" style="padding-bottom: 65px"><span class="red">*</span> 接待内容</td>
                  <td width="18%" class="ybox04tdr" colspan="5">
                     <textarea rows="5" cols="150" name="reception_content" id="reception_content"></textarea>
                  </td>
                  
              </tr>
              <tr><td class="ybox04tdr" colspan="6">
               <dl>
                 <dt><strong>【注】</strong> 
                 1.基本信息为必填项</br>
                 2.详细信息必须在用户下订单之前填写完整
              </dt>
               </dl>
            </td>
            </tr>
            
          </table></td>
        <td class="ybox03td6"></td>
      </tr>
      <tr>
        <td class="ybox03td7"></td>
        <td class="ybox03td8"></td>
        <td class="ybox03td9"></td>
      </tr>
    </table>
    <table width="380" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="60" align="center"> <img src="images/bottoncommit.gif"  style="cursor: pointer;"width="95" height="34" onclick="return checkreception_content()&&ajaxUpdate()" /></td>
        <td height="60" align="center"><img src="images/bottonreset.gif" style="cursor: pointer;" width="95" height="34" onclick="ajaxReset()" /></td>
      </tr>
    </table>
  </div>
</div>
</body>
</html>
